package com.ayoka.adapter;

import com.ayoka.R;
import com.ayoka.mvp.CourseAssignmentMVP.CourseAssignmentModel.RequestRelationScoreBean;
import com.ayoka.widget.RuleSeekBar;
import com.jcp.baselibrary.brvah.BaseQuickAdapter;
import com.jcp.baselibrary.brvah.BaseViewHolder;

import java.util.List;

/**
 * Created by jinchunping on 2018/4/11.
 */

public class CourseAssignmentGradeOptionAdapter extends BaseQuickAdapter<RequestRelationScoreBean, BaseViewHolder> {


    public CourseAssignmentGradeOptionAdapter() {
        super(R.layout.item_course_assignment_grade_option, null);
    }

    @Override
    protected void convert(final BaseViewHolder holder, final RequestRelationScoreBean item) {
        if (item == null) {
            holder.setVisible(R.id.ll_grade_container, false)
                    .setVisible(R.id.ll_add_container, true)
                    .addOnClickListener(R.id.iv_add_grade_item);
        } else {
            holder.setVisible(R.id.ll_grade_container, true)
                    .setVisible(R.id.ll_add_container, false);
            holder.setText(R.id.tv_title, item.ItemName)
                    .addOnClickListener(R.id.iv_delete_grade_item);
            RuleSeekBar ruleSeekBar = holder.getView(R.id.seek_bar);
            ruleSeekBar.setCurrentProgress(item.Score);
            ruleSeekBar.setOnRangeRulerChangeListener(new RuleSeekBar.OnRangeRulerChangeListener() {
                @Override
                public void onValueChanged(int value) {
                    item.Score = value;
                }
            });
        }
    }
}
